//using System;
//using Microsoft.Xna.Framework;
//using Microsoft.Xna.Framework.Graphics;
//using Microsoft.Xna.Framework.Input;
//using Phoenix.Xna.Framework.Components.Cameras;
//using Phoenix.Xna.Framework.Graphics;
//using Phoenix.Xna.Framework.Graphics.Primitives;
//using Phoenix.Xna.Framework.FrameworkExtensions;

//namespace Phoenix.Xna.Framework.Components.Sky
//{
//    public class SkyDome : DrawableComponent
//    {
//        private SkyDomeShader _shader;
//        private SkyDomeShaderState _state;

//        public float Theta { get; set; }
//        public float Phi { get; set; }
//        public bool RealTime { get; set; }

//        public SkyDome()
//            : base()
//        {
//            RealTime = false;
//            Theta = 0.0f;
//            Phi = 0.0f;
//        }

//        public override void LoadContent()
//        {
//            _state = new SkyDomeShaderState();
//            _shader = new SkyDomeShader(@"SkyDome/EffectMaps/SkyDome");
//            base.LoadContent();

//        }

//        public override void Update(GameTime gameTime)
//        {
//            if (RealTime)
//            {
//                int minutes = DateTime.Now.Hour * 60 + DateTime.Now.Minute;
//                this.Theta = (float)minutes * (float)(Math.PI) / 12.0f / 60.0f;
//            }
            
//            _shader.Theta = Theta;
//            _state.SunlightColor = GetSunColor(-_state.Theta, 2);
//            _state.SunlightDirection = GetDirection();
//            base.Update(gameTime);
//        }

//        public override void Draw(GameTime gameTime)
//        {        
//            _shader.Draw(gameTime, _state);
//        }

//        private Vector3 GetDirection()
//        {

//            float y = (float)Math.Cos((double)this.Theta);
//            float x = (float)(Math.Sin((double)this.Theta) * Math.Cos(this.Phi));
//            float z = (float)(Math.Sin((double)this.Theta) * Math.Sin(this.Phi));
//            return new Vector3(x, y, z);
//        }

//        private Vector3 GetSunColor(float fTheta, int nTurbidity)
//        {
//            float fBeta = 0.04608365822050f * nTurbidity - 0.04586025928522f;
//            float fTauR, fTauA;
//            float[] fTau = new float[3];

//            float cosine = (float)Math.Cos((double)fTheta + Math.PI);
//            double factor = (double)fTheta / Math.PI * 180.0;
//            double jarl = Math.Pow(93.885 - factor, -1.253);
//            float potential = (float)jarl;
//            float m = 1.0f / (cosine + 0.15f * potential);

//            int i;
//            float[] fLambda = new float[3];
//            Vector3 wavelength = _shader.Wavelength;
//            fLambda[0] = wavelength.X;
//            fLambda[1] = wavelength.Y;
//            fLambda[2] = wavelength.Z;


//            for (i = 0; i < 3; i++)
//            {
//                potential = (float)Math.Pow((double)fLambda[i], 4.0);
//                fTauR = (float)Math.Exp((double)(-m * 0.008735f * potential));

//                const float fAlpha = 1.3f;
//                potential = (float)Math.Pow((double)fLambda[i], (double)-fAlpha);
//                if (m < 0.0f)
//                    fTau[i] = 0.0f;
//                else
//                {
//                    fTauA = (float)Math.Exp((double)(-m * fBeta * potential));
//                    fTau[i] = fTauR * fTauA;
//                }

//            }

//            Vector3 vAttenuation = new Vector3(fTau[0], fTau[1], fTau[2]);
//            return vAttenuation;
//        }
//    }
//}